package Week2.J0425;

public class 最长回文子串_xv {

    public static void main(String[] args) {
        String A = "b";
        System.out.println(getLongestPalindrome(A));
    }
    public static int getLongestPalindrome (String s) {
        int left = 0;
        int right = 0;
        int count = 0;

        for (int i = 0; i < s.length(); i++) {
            left = i - 1;
            right = i + 1;
            while (left >= 0 && right < s.length() && s.charAt(left) == s.charAt(right)) {
                left--;
                right++;
            }
            count = Math.max(count, right-left-1);

            left = i;
            right = i + 1;
            while (left >= 0 && right < s.length() && s.charAt(left) == s.charAt(right)) {
                left--;
                right++;
            }
            count = Math.max(count, right-left-1);
        }
        return count;
    }
}
